package com.glsc.ngateway.common.base.domain.mysql.gateway.other;

import cn.hutool.core.annotation.Alias;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;

/**
 * 堡垒机
 */
@Data
@Entity
@Table(name = "t_gw_fortress")
@EqualsAndHashCode(callSuper=false)
public class Fortress implements Serializable {

    @ApiModelProperty(value = "id")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @Column(name = "account")
    @Alias(value = "用户")
    @ApiModelProperty(value = "用户")
    private String account;

    @Column(name = "machine")
    @Alias(value = "资产")
    @ApiModelProperty(value = "资产")
    private String machine;

    @Column(name = "account_validity_from", columnDefinition = "date comment '账号有效期(从)'")
    @Alias(value = "账号有效期(从)")
    @ApiModelProperty(value = "账号有效期(从)")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate accountValidityFrom;

    @Column(name = "account_validity_end", columnDefinition = "date comment '账号有效期(到)'")
    @Alias(value = "账号有效期(到)")
    @ApiModelProperty(value = "账号有效期(到)")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate accountValidityEnd;

    @Column(name = "`group`")
//    @Alias(value = "资产组")
    @ApiModelProperty(value = "资产组")
    private String group;

    @Column(name = "auth")
//    @Alias(value = "账号")
    @ApiModelProperty(value = "账号")
    private String auth;

    @Column(name = "protocol")
//    @Alias(value = "协议")
    @ApiModelProperty(value = "协议")
    private String protocol;

    @Column(name = "template")
//    @Alias(value = "规则模板")
    @ApiModelProperty(value = "规则模板")
    private String template;

    @Column(name = "`from`")
//    @Alias(value = "来源")
    @ApiModelProperty(value = "来源")
    private String from;

    @Column(name = "`status`")
    @Alias(value = "状态")
    @ApiModelProperty(value = "状态")
    private String status;

    @Column(name = "role")
    @Alias(value = "角色")
    @ApiModelProperty(value = "role")
    private String role;

    @Column(name = "department_one")
    @ApiModelProperty(value = "一级部门")
    private String departmentOne;

    @Column(name = "department_one_id")
    @ApiModelProperty(value = "一级部门id")
    private Integer departmentOneId;

    @Column(name = "department_two")
    @Alias(value = "部门")
    @ApiModelProperty(value = "二级部门")
    private String departmentTwo;

    @Column(name = "department_two_id")
    @ApiModelProperty(value = "二级部门id")
    private Integer departmentTwoId;

    @Column(name = "name")
    @Alias(value = "姓名")
    @ApiModelProperty(value = "姓名")
    private String name;

    @Column(name = "system_code")
    @ApiModelProperty(value = "系统编号")
    private String systemCode;

    @Column(name = "system_name")
    @Alias(value = "系统名")
    @ApiModelProperty(value = "系统名称")
    private String systemName;

//    @Column(name = "not_oa")

    @ApiModelProperty(value = "非oa，1非oa，0是oa，默认导出oa的数据")
    @Column(name = "not_oa")
    private Integer notOa;

    //创建时间
    @Column(name = "create_time",updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//json序列化实体类处理
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "Position")
    @Alias(value = "岗位")
    @Column(name = "position")
    private String position;

    @ApiModelProperty(value = "remark")
    @Column(name = "remark")
    @Alias(value = "备注")
    private String remark;

}
